package com.lovo.practice_7_12;

import java.rmi.MarshalledObject;
import java.sql.SQLOutput;
import java.util.*;
import java.util.concurrent.ForkJoinPool;

public class J189_7_12 {

    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<Integer, String>();
        map.put(1, "Amy");
        map.put(2, "Joe");
        map.put(3, "Tom");
        map.put(4, "Susan");
//1
        Set set = new HashSet();
        set = map.keySet();
        for (Object i : set) {
            System.out.println(i + " " + map.get(i));
        }
//2
        map.put(5, "Wang");
//3
        map.remove(4);
//4
        map.put(3, "Tommy");
//5
        System.out.println();
        for (Object i : set) {
            System.out.println(i + " " + map.get(i));
        }
        //6
        String[] strings = {"a", "b", "a", "b", "c", "a", "b", "c", "b"};
        Map<String, Integer> map1 = new HashMap<String, Integer>();
        for (int i = 0; i < strings.length; i++) {
            map1.put(strings[i], 0);
        }
        Set<String> set1 = map1.keySet();
        ArrayList list = new ArrayList<String>();
        list.addAll(set1);
        int[] count = new int[set.size()];
        Map<String, Integer> map2 = new HashMap<String, Integer>();
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < strings.length; j++) {
                if (list.get(i).equals(strings[j])) {
                    count[i]++;
                } else {
                    continue;
                }
                map2.put(String.valueOf(list.get(i)), count[i]);
            }
        }
        System.out.println(map2);
    }
}
